// Decompiled by GOOSIN CO,LTD Copyright 2010 Pavel Kouznetsov.
// home page: http://www.Goosin.net
// Decompiler options: packimports(3) fieldsfirst ansi space 
// Source File Name:   itemName_change_ok.java

package manufacture.config.procedure;

import include.nseer_cookie.exchange;
import include.nseer_db.nseer_db_backup1;
import java.io.IOException;
import java.sql.ResultSet;
import java.util.StringTokenizer;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.*;
import javax.servlet.jsp.JspFactory;

public class itemName_change_ok extends HttpServlet
{

	ServletContext application;
	HttpSession session;

	public itemName_change_ok()
	{
	}

	public synchronized void service(HttpServletRequest request, HttpServletResponse response)
		throws IOException, ServletException
	{
		HttpSession dbSession = request.getSession();
		JspFactory _jspxFactory = JspFactory.getDefaultFactory();
		javax.servlet.jsp.PageContext pageContext = _jspxFactory.getPageContext(this, request, response, "", true, 8192, true);
		ServletContext dbApplication = dbSession.getServletContext();
		nseer_db_backup1 manufacture_db = new nseer_db_backup1(dbApplication);
		nseer_db_backup1 security_db = new nseer_db_backup1(dbApplication);
		try
		{
			if (manufacture_db.conn((String)dbSession.getAttribute("unit_db_name")) && security_db.conn((String)dbSession.getAttribute("unit_db_name")))
			{
				String id = request.getParameter("id");
				String type_ID = request.getParameter("type_ID");
				String type_name = request.getParameter("type_name");
				String bodyc = new String(request.getParameter("describe1").getBytes("UTF-8"), "UTF-8");
				String describe1 = exchange.toHtml(bodyc);
				String register_ID = request.getParameter("register_ID");
				String responsible_person = "";
				int n = 0;
				int m = 0;
				String sql2;
				for (StringTokenizer tokenTO6 = new StringTokenizer(register_ID, ", "); tokenTO6.hasMoreTokens();)
				{
					sql2 = (new StringBuilder("insert into hr_config_human_id_temp(human_ID) values('")).append(tokenTO6.nextToken()).append("') ").toString();
					security_db.executeUpdate(sql2);
					m++;
				}

				sql2 = "select distinct human_ID from hr_config_human_id_temp";
				ResultSet rs2 = security_db.executeQuery(sql2);
				rs2.last();
				if (rs2.getRow() != m)
					n++;
				sql2 = "delete from hr_config_human_id_temp";
				security_db.executeUpdate(sql2);
				for (StringTokenizer tokenTO = new StringTokenizer(register_ID, ", "); tokenTO.hasMoreTokens();)
				{
					sql2 = (new StringBuilder("select * from security_users where human_ID='")).append(tokenTO.nextToken()).append("'").toString();
					rs2 = security_db.executeQuery(sql2);
					if (rs2.next())
						responsible_person = (new StringBuilder(String.valueOf(responsible_person))).append(rs2.getString("human_name")).append(", ").toString();
					else
						n++;
				}

				if (n != 0)
				{
					response.sendRedirect("manufacture/config/procedure/itemName_change_ok_a.jsp");
				} else
				{
					String sql = (new StringBuilder("update manufacture_config_public_char set type_ID='")).append(type_ID).append("',type_name='").append(type_name).append("',describe1='").append(describe1).append("',register_ID='").append(register_ID).append("' where id='").append(id).append("'").toString();
					manufacture_db.executeUpdate(sql);
					response.sendRedirect("manufacture/config/procedure/itemName_change_ok_b.jsp");
				}
				security_db.commit();
				manufacture_db.commit();
				security_db.close();
				manufacture_db.close();
			} else
			{
				response.sendRedirect("error_conn.htm");
			}
		}
		catch (Exception ex)
		{
			ex.printStackTrace();
		}
	}
}
